<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <meta name="renderer" content="webkit">
    <title>{$Think.HEAD_TITLE}</title>
    <link rel="stylesheet" href="__css__/base.css">
    <link rel="stylesheet" href="__css__/loginstyle.css">
</head>
<body>
<?php
	$username = session('username');
	if(!empty($username )){  ?>
<script type="text/javascript">
    window.location.href = "{:url('admin/index/index')}";
</script>
<?php  } ?>
<div class="bg"></div>
<div class="container">
    <div class="line bouncein">
        <div class="xs6 xm4 xs3-move xm4-move">
            <div style="height:150px;"></div>
            <div class="media media-y margin-big-bottom">
            </div>
            <form action="#" method="post">
                <div class="panel loginbox">
                    <div class="text-center margin-big padding-big-top">
                        <h1>{$Think.HEAD_TITLE}</h1>
                    </div>
                    <div class="panel-body" style="padding:30px; padding-bottom:10px; padding-top:10px;">
                        <div class="form-group">
                            <div class="field field-icon-right">
                                <input type="text" class="input input-big" name="name" id="username" placeholder="登录账号">
                                <span class="icon icon-user margin-small"></span>
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="field field-icon-right">
                                <input type="password" class="input input-big" name="password" id="password"
                                       placeholder="登录密码">
                                <span class="icon icon-key margin-small"></span>
                            </div>
                        </div>
                    </div>
                    <div style="padding:30px;">
                        <input type="button" id="button" class="button button-block bg-main text-big input-big"
                               onclick="login()" value="登录">
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
<script src="__js__/jquery.min.js"></script>
<script src="__module__/layer/layer.js"></script>

<script>
    function login() {
        var username = $('#username').val();
        var password = $('#password').val();
        $.ajax({
            url: 'login',
            type: 'post',
            dataType: 'json',
            data: {
                username: username,
                password: password
            },
        }).done(function (data) {
            // console.log(data);
            if (data.code == 0) {
                layer.msg(data.msg);
            } else {
                layer.msg(data.msg, {icon: 1}, function () {
                    location.href = "index/index";
                });

            }
        })
    }

    document.onkeydown = function (e) {
        var ev = document.all ? window.event : e;
        if (ev.keyCode == 13) {
            login();
        }
    }
</script>
</body>
</html>